<template>
  <el-row>
    <iframeDemo :url="url" :height="height" @handelSave="handleSave" />
  </el-row>
</template>

<script>
import TopManu from "@/components/TopMenu";
import iframeDemo from "@/components/iframeDemo/index.vue"
import {iframeUrl} from "@/utils/server.js"
let that
export default {
  data(){
    return {
      url:"",
      height:"0"
    }
  },
  mounted(){
     that = this
     let data = JSON.parse(localStorage.getItem("formHtml"))
     console.log(data)
    //  this.height = (document.body.clientHeight - 150) + 'px'
     this.url = `${iframeUrl}/#/caselist2?id=${data.id}&uid=${data.uid}&type=${data.type}&tlp_name=${data.tlp_name}&token=${localStorage.getItem("token")}&category_id=${data.category_id}`
      window.addEventListener("message", function(data) {
      if(data.data.code == 200){
        that.$store.state.tagsView.visitedViews.forEach(item=>{
          if(item.name == "compile"){
            that.$store.state.tagsView.visitedViews.splice(that.$store.state.tagsView.visitedViews.findIndex(item => item.path === that.$route.path), 1)
            that.$router.push("/workstation/caseList")
          }
        })
      }
      }, false);
  },
  methods:{

    handleSave(){
      console.log("保存成功")
    },
    // 传值请求保存
    sendBtn(){
        let iframe = document.getElementById('iframe_demo');
        let json = {
          code:200
        };
        iframe.contentWindow.postMessage(json, '*');
    },
  },
  components:{
    iframeDemo,
    TopManu
  },
}
</script>

<style>

</style>
